import Cookies from 'js-cookie'
const TokenKey = '1234tv-token'
const pathTokenKey = '1234tv-path'
const wechatLoginStatusTokenKey = '1234tv-wechat-login-status'
const passwordTokenkey = '1234tv-room-password'
import storage from 'good-storage'
export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token , { expires: 7 })
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getPath() {
  return Cookies.get(pathTokenKey)
}

export function setPath(path) {
  return Cookies.set(pathTokenKey, path)
}

export function removePath() {
  return Cookies.remove(pathTokenKey)
}

export function getWechatLoginStatus() {
  return Cookies.get(wechatLoginStatusTokenKey)
}

export function setWechatLoginStatus(status) {
  return Cookies.set(wechatLoginStatusTokenKey, status)
}

export function removeWechatLoginStatus() {
  return Cookies.remove(wechatLoginStatusTokenKey)
}

export function getRoomPassword(key) {
  return Cookies.get(passwordTokenkey + '-' + key)
}

export function setRoomPassword(password,key) {
	var inFiveMinutes = new Date(new Date().getTime() + 5 * 60 * 1000)
  return Cookies.set(passwordTokenkey + '-' + key, password,{
    expires: inFiveMinutes
	})
}

export function removeRoomPassword(key) {
  return Cookies.remove(passwordTokenkey + '-' + key)
}

export function saveCookie (key, value, options) {
  Cookies.set(key, value, options)
  return value
}

export function loadCookie (key, defaultValue) {
  return Cookies.get(key) || defaultValue
}

export function removeCookie (key) {
  Cookies.remove(key)
  return ''
}

export function saveStorage (key, value) {
  storage.set(key, value)
  return value
}

export function loadStorage (key, defaultValue) {
  return storage.get(key, defaultValue)
}

export function removeStorage (key) {
  storage.remove(key)
  return ''
}